package com.edu.service.shop.impl;


import com.edu.entity.shop.*;
import com.edu.entity.user.SysUser;
import com.edu.mapper.shop.VideoMapper;
import com.edu.service.shop.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class VideoServiceImpl implements VideoService {
    public static Integer CURRENT_PAGE=1;
    public static Integer PAGE_SIZE=4;
    @Autowired
    private VideoMapper videoMapper;
    @Override
    public List<Video> findListByName(String brief,Integer page,Integer size) {
        if(page!=null){
            CURRENT_PAGE=page;
        }
        if(size!=null){
            PAGE_SIZE=size;
        }
        Vo vo=new Vo(brief,(CURRENT_PAGE-1)*PAGE_SIZE,PAGE_SIZE);
        return videoMapper.findListByName(vo);
    }

    @Override
    public Integer findCount(String brief) {
        return videoMapper.findCount(brief);
    }

    @Override
    public SysUser findUserByPrin(String username) {
        return videoMapper.findUserByPrin(username);
    }

    @Override
    public void insertCollect(Integer id, Integer prinId, Date date) {
        Collect collect=new Collect(id,prinId,date);
        videoMapper.insertCollect(collect);
    }

    @Override
    public List<Video> findVideoRecent() {
        return videoMapper.findVideoRecent();
    }
    @Override
    public List<Video> findVideoMost() {
        return videoMapper.findVideoMost();
    }
    @Override
    public Video findVideoById(Integer id) {
        return videoMapper.selectById(id);
    }
    @Override
    public List<Video> findListByTag(String tag) {
        return videoMapper.findListByTag(tag);
    }
    @Override
    public List<Video> findListByTag2(String tag) {
        return videoMapper.findListByTag2(tag);
    }

    @Override
    public Integer findPid(Integer pid) {
        return videoMapper.findPid(pid);
    }

    @Override
    public List<Video> findVideoPid(Integer id) {
        return videoMapper.findVideoPid(id);
    }

    @Override
    public List<Comments> findCommentsById(Integer id) {
        return videoMapper.findCommentsById(id);
    }

    @Override
    public Integer findGraAndSubCount(String grade, String subject) {
        VoGraAndSub voGraAndSub=new VoGraAndSub(grade,subject);
        return videoMapper.findGraAndSubCount(voGraAndSub);
    }

    @Override
    public List<Video> findGraAndSubListByName(String grade, String subject, Integer page, Integer size) {
        if(page!=null){
            CURRENT_PAGE=page;
        }
        if(size!=null){
            PAGE_SIZE=size;
        }
        VoGraAndSub voGraAndSub=new VoGraAndSub(grade,subject,(CURRENT_PAGE-1)*PAGE_SIZE,PAGE_SIZE);
        return videoMapper.findGraAndSubListByName(voGraAndSub);
    }

    @Override
    public List<Video> pageList() {
        return videoMapper.pageList();
    }

    @Override
    public Video top(int id) {
        return videoMapper.top(id);
    }


}
